package actions.staffs;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.lang.xwork.StringUtils;
import org.apache.struts2.ServletActionContext;

import actions.base.BaseAction;
import data.Staff;

public class Edit extends BaseAction {

	Staff staff;

	@Override
	public String execute() throws Exception {
		HttpServletRequest request = ServletActionContext.getRequest();
		String value = request.getParameter("id");
		if (StringUtils.isNotEmpty(value)) {
			int id = Integer.parseInt(value);
			staff = services.getStaffByID(id);
		}else{
			services.updateStaff(staff);
		}
		return SUCCESS;
	}

	/**
	 * Gets the staff.
	 * 
	 * @return the staff
	 */
	public Staff getStaff() {
		return staff;
	}

	/**
	 * @param staff
	 *            the staff to set
	 */
	public void setStaff(Staff staff) {
		this.staff = staff;
	}

}
